<template>
	<view class="container">
		<z-paging ref="paging" v-model="itemList" @query="queryList" :fixed="false" :auto="true"
			empty-view-img="/static/empty.png" empty-view-text="暂无数据~" :empty-view-img-style="imgStyle">
			<view slot="top">
				<u-navbar height="50" title="平台公告" title-color="#333" title-size="36">
				</u-navbar>
			</view>
			<view class="messageView" v-for="(item,index) in itemList" :key="index">
				<view class="messageTitle u-line-1">{{item.title}}</view>
				<view class="messageTime">{{item.created_at}}</view>
				<view class="messageContent">
					<u-parse :html="item.content"></u-parse>
				</view>
				<view class="line"></view>
				<view class="messageShow" @click="onDetails(item)">
					<view style="flex: 1;">查看详情</view>
					<u-icon size="15" name="/static/next.png"></u-icon>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				itemList: [],
				imgStyle: {
					width: '12rem',
					height: '9rem'
				}
			}
		},
		onLoad() {
			this.$nextTick(function() {
				this.$refs.paging.reload();
			});
		},
		methods: {
			queryList(page, pageSize) {
				let self = this;
				self.$shops.noticeList({
					limit: pageSize,
					page: page
				}, true).then(res => {
					self.$refs.paging.complete(res.data);
				}).catch(res => {
					self.$refs.paging.complete();
				});
			},
			onDetails(item) {
				uni.navigateTo({
					url: '/other/web-data/web-data?type=2&id=' + item.id
				});
			}
		}
	}
</script>

<style>
	@import url('notice.css');

	page {
		height: 100%;
		background: #f5f5f5;
	}
</style>
